<?php
/**
 *@file comment.php
 *@author Zhe.Zhou(zhouzhe@haibao.com)
 *@date 2015-7-29 下午4:19:39
 *@brief  
 */
namespace haibao\app\business;

use haibao\frame\data\query\Condition;

class CommentBan extends Base{
    
    /**
     * @var $_instance
     */
    private static $_instance;
    
    /**
     * instance()
     */
    private static function instance(){
        if(!self::$_instance){
            self::$_instance = new \haibao\app\data\CommentBan();
        }
        return self::$_instance;
    }
    
    public static function getBanById($userId){
        return self::instance()->getBanById($userId);
    }
    
	public static function addCommentBan($commentBanModel){
		\haibao\cms\business\Base::checkOperation(\haibao\cms\business\Base::FUNC_CODE_COMMENT_BAN_ADD);
		self::instance()->add($commentBanModel);
		self::saveOperateHistory(\haibao\cms\business\Base::FUNC_CODE_COMMENT_BAN_ADD, $commentBanModel->toArray(true,true));
	}
	
    public static function updateComment($id,$arrSet){
		\haibao\cms\business\Base::checkOperation(\haibao\cms\business\Base::FUNC_CODE_COMMENT_BAN_ADD);
		self::instance()->updateById($id, $arrSet);
		\haibao\cms\business\Base::saveOperateHistory(\haibao\cms\business\Base::FUNC_CODE_COMMENT_BAN_ADD, $arrSet);
	}
	
	public static function checkBanOrNot($userId){
		$commentBanFilter = new \haibao\app\model\filter\CommentBan();
		if($userId){
			$commentBanFilter->where($commentBanFilter::CONDITION_FIELD_NAME_USER_ID, Condition::CONDITION_EQUAL, $userId);
		}else{
			throw new BusinessException('验证失效，无效用户Id');
		}
		return self::instance()->getOne($commentBanFilter);
	}
	
	public static function removeByUserId($filter){
		self::instance()->remove($filter);
	}
	
	/**
	 * 获取用户禁言表
	 */
	public static function getUserBanList($model){
		return self::instance()->getUserBanList($model);
	}
	

}